import { Injectable } from "@angular/core";
import { UserInfoDto } from "@shared/service-proxies/service-proxies";

@Injectable()
export class UserHelper {

    newPostLevelValToName(postLevelVal: number) {
        return abp.custom.newPostLevelValToName[postLevelVal];
    }

    isResponsibleLeader(userInfoDto: UserInfoDto) {
        return this.newPostLevelValToName(userInfoDto.newPostLevel) === "分管领导";
    }

    isMainLeaders(userInfoDto: UserInfoDto) {
        return this.isGeneralManager(userInfoDto) || this.isChairman(userInfoDto);
    }

    isGeneralManager(userInfoDto: UserInfoDto) {
        return this.newPostLevelValToName(userInfoDto.newPostLevel) === "总经理";
    }

    isChairman(userInfoDto) {
        return this.newPostLevelValToName(userInfoDto.newPostLevel) === "董事长";
    }

    userSort(arr) {
        if (!arr) return;
        arr.sort((a, b) => b.order - a.order);
    }
}

